<html>
<head><meta charset="utf-8"><title>async vs generator stabilization · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html">async vs generator stabilization</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="133974007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974007">(Sep 14 2018 at 19:24)</a>:</h4>
<p>Last I heard, async/await is built on top of generators. When async/await stabilizes, will generators <em>also</em> stabilize?</p>



<a name="133974043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974043">(Sep 14 2018 at 19:25)</a>:</h4>
<p>there is no need to do that and many reasons not to, they're two rather different features after all</p>



<a name="133974168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974168">(Sep 14 2018 at 19:28)</a>:</h4>
<p>Sure, but people <em>also</em> want generators</p>



<a name="133974182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974182">(Sep 14 2018 at 19:29)</a>:</h4>
<blockquote>
<p>many reasons not to</p>
</blockquote>
<p>May I find a list of those somewhere?</p>



<a name="133974185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974185">(Sep 14 2018 at 19:29)</a>:</h4>
<p>probably in the tracking issue...</p>



<a name="133974193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974193">(Sep 14 2018 at 19:29)</a>:</h4>
<blockquote>
<p>Sure, but people <em>also</em> want generators</p>
</blockquote>
<p>yeah but i don't see what that has to do with tying the stabilization of generators to the stabilization of async/await</p>



<a name="133974283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974283">(Sep 14 2018 at 19:31)</a>:</h4>
<p>i'm sure you can find a bunch of unresolved questions in the tracking issue but the underlying reason is, it's a big and complicated feature and the only merged RFC for it was an <em>experimental</em> one</p>



<a name="133974285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974285">(Sep 14 2018 at 19:31)</a>:</h4>
<p>One <em>possible</em> reason that it would require it is if async/await were merely desugared to generators. I believe that to be the case at some point in the past.</p>



<a name="133974344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974344">(Sep 14 2018 at 19:32)</a>:</h4>
<p>no, stable surface syntax can desugar to unstable things. e.g. the desugaring for <code>?</code> uses (or for the longest time used) an unstable trait</p>



<a name="133974345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974345">(Sep 14 2018 at 19:32)</a>:</h4>
<p>I'm also assuming that if async await is battle-hardened enough to stabilize, then transitively so must generators</p>



<a name="133974347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974347">(Sep 14 2018 at 19:32)</a>:</h4>
<p>the difference is</p>



<a name="133974349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974349">(Sep 14 2018 at 19:32)</a>:</h4>
<p>we are not wanting to stabilize the traits that generators implement</p>



<a name="133974350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974350">(Sep 14 2018 at 19:33)</a>:</h4>
<p>and various other details</p>



<a name="133974361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974361">(Sep 14 2018 at 19:33)</a>:</h4>
<p>which are not "exposed" by the async/await pattern</p>



<a name="133974365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974365">(Sep 14 2018 at 19:33)</a>:</h4>
<p>not to say it wouldn't be nice!</p>



<a name="133974368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974368">(Sep 14 2018 at 19:33)</a>:</h4>
<p>I'd love to be able to write iterators in line</p>



<a name="133974377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974377">(Sep 14 2018 at 19:33)</a>:</h4>
<p>I wonder if you can abuse async await to do that... :P</p>



<a name="133974442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974442">(Sep 14 2018 at 19:35)</a>:</h4>
<p>Is it valid to say that async/await uses a subset of (possible?) generator functionality?</p>



<a name="133974464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974464">(Sep 14 2018 at 19:35)</a>:</h4>
<p>e.g., as <span class="user-mention" data-user-id="124289">@rkruppe</span> says </p>
<blockquote>
<p>it's a big and complicated feature</p>
</blockquote>



<a name="133974482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974482">(Sep 14 2018 at 19:36)</a>:</h4>
<blockquote>
<p>Is it valid to say that async/await uses a subset of (possible?) generator functionality?</p>
</blockquote>
<p>that is true</p>



<a name="133974525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974525">(Sep 14 2018 at 19:36)</a>:</h4>
<p>e.g., you can only yield <code>()</code> values :)</p>



<a name="133974533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974533">(Sep 14 2018 at 19:36)</a>:</h4>
<p>not that this is a point of contention</p>



<a name="133974621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974621">(Sep 14 2018 at 19:38)</a>:</h4>
<blockquote>
<p>e.g., you can only yield <code>()</code> values :)</p>
</blockquote>
<p>huh. I would have naïvely expected that the <code>Future</code>'s / <code>Stream</code>'s <code>Item</code> would have been yielded. I guess instead it's just yielding to go to the next step in the state machine (starting to talk out of my depth here)</p>



<a name="133974656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974656">(Sep 14 2018 at 19:39)</a>:</h4>
<p>No, the yields occur when an <code>await</code> cannot complete immediately</p>



<a name="133974664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974664">(Sep 14 2018 at 19:39)</a>:</h4>
<p>the <code>Item</code> is "returned", I believe</p>



<a name="133974729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974729">(Sep 14 2018 at 19:40)</a>:</h4>
<p>(This is where I wish that RFCs / the reference was updated with post-implementation changes, so I could go spelunking without looking into source code)</p>



<a name="133974836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974836">(Sep 14 2018 at 19:42)</a>:</h4>
<p>On a scale of "no big" to "woah", any gut feelings on how much code is needed to go from what async/await uses now(-ish) to completing  a hypothetical generators RFC?</p>



<a name="133974866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974866">(Sep 14 2018 at 19:43)</a>:</h4>
<p>probably very little code but triple digit number of comments of bikeshedding</p>



<a name="133974939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/async%20vs%20generator%20stabilization/near/133974939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/async.20vs.20generator.20stabilization.html#133974939">(Sep 14 2018 at 19:44)</a>:</h4>
<p>My first version of that comment was "what it would take to go from" and I realized that would include such discussions, so I tried to focus on what I was more interested in <span class="emoji emoji-1f609" title="wink">:wink:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>